#include "pageautoverify.h"

pageAutoVerify::pageAutoVerify(QWidget *parent) :
    QWidget(parent)
{
    isSelectCurrAll = false;
    isSelectVoltAll = false;
    page = 1;
    layoutMain();
}

void pageAutoVerify::layoutMain()
{
    QFont ft;
    ft.setPixelSize(20);

    widTestPrjForm = new QWidget;
    layTestPrjPart(widTestPrjForm);

    widDataTP = new QWidget;
    layDataTP(widDataTP);

    widDataCP = new QWidget;
    layDataCP(widDataCP);

    widDataCURR = new QWidget;
    layDataCURR(widDataCURR);

    widDataVOLT = new QWidget;
    layDataVOLT(widDataVOLT);

    theStaWid = new QStackedWidget;
    theStaWid->addWidget(widTestPrjForm);


    btnTest = new QPushButton("开始测量");
    btnTest->setFont(ft);
    btnTest->setFixedHeight(40);
    //connect(btnTest,SIGNAL(clicked()),this,SLOT(test()));

    btnPre = new QPushButton("上一页");
    btnPre->setFont(ft);
    btnPre->setFixedHeight(40);
    connect(btnPre,SIGNAL(clicked()),this,SLOT(prePage()));
    btnPre->setVisible(false);

    btnNext = new QPushButton("下一页");
    btnNext->setFont(ft);
    btnNext->setFixedHeight(40);
    connect(btnNext,SIGNAL(clicked()),this,SLOT(nextPage()));
    btnNext->setVisible(false);

    QHBoxLayout *HlayButton = new QHBoxLayout;
    HlayButton->addWidget(btnTest);
    HlayButton->addWidget(btnPre);
    HlayButton->addWidget(btnNext);

    QVBoxLayout *layoutMain = new QVBoxLayout;
    layoutMain->setAlignment(Qt::AlignCenter);
    layoutMain->addWidget(theStaWid);
    layoutMain->addLayout(HlayButton);
    layoutMain->addSpacing(20);
    layoutMain->setContentsMargins(0,0,0,0);

    setLayout(layoutMain);
}

void pageAutoVerify::layTestPrjPart(QWidget *theWidget)
{
    QFont ft;
    ft.setPixelSize(25);

    setStyleSheet(".QCheckBox{color:white;}");

    chkTP = new QCheckBox("时间性能检验");
    chkTP->setFont(ft);
    chkTP->setChecked(true);

    chkCP = new QCheckBox("通信性能检验");
    chkCP->setFont(ft);
    chkCP->setChecked(true);

    QVBoxLayout *Vlay1st = new QVBoxLayout;
    Vlay1st->addWidget(chkTP);
    Vlay1st->addWidget(chkCP);

    labAP = new QLabel("准确度检验");
    labAP->setFont(ft);

    QLabel *labDemo = new QLabel;
    labDemo->setStyleSheet(".QLabel{background-color:white;}");

    ft.setPixelSize(20);
    chkCURR = new QCheckBox("测量用电流");
    chkCURR->setFont(ft);
    chkCURR->setTristate();
    connect(chkCURR,SIGNAL(stateChanged(int)),this,SLOT(SelectAllCurrTestPoint(int)));
    connect(chkCURR,SIGNAL(clicked()),this,SLOT(changeCurrState()));

    chkCURR_5 = new QCheckBox("5%检定点");
    chkCURR_5->setFont(ft);
    connect(chkCURR_5,SIGNAL(clicked()),this,SLOT(onStateChanged_Curr()));

    chkCURR_20 = new QCheckBox("20%检定点");
    chkCURR_20->setFont(ft);
    connect(chkCURR_20,SIGNAL(clicked()),this,SLOT(onStateChanged_Curr()));

    chkCURR_100 = new QCheckBox("100%检定点");
    chkCURR_100->setFont(ft);
    connect(chkCURR_100,SIGNAL(clicked()),this,SLOT(onStateChanged_Curr()));

    chkCURR_120 = new QCheckBox("120%检定点");
    chkCURR_120->setFont(ft);
    connect(chkCURR_120,SIGNAL(clicked()),this,SLOT(onStateChanged_Curr()));

    QVBoxLayout *Vlay2nd = new QVBoxLayout;
    Vlay2nd->addWidget(chkCURR);
    Vlay2nd->addWidget(chkCURR_5);
    Vlay2nd->addWidget(chkCURR_20);
    Vlay2nd->addWidget(chkCURR_100);
    Vlay2nd->addWidget(chkCURR_120);

    chkVOLT = new QCheckBox("测量用电压");
    chkVOLT->setFont(ft);
    connect(chkVOLT,SIGNAL(stateChanged(int)),this,SLOT(SelectAllVoltTestPoint(int)));
    connect(chkVOLT,SIGNAL(clicked()),this,SLOT(changeVoltState()));

    chkVOLT_20 = new QCheckBox("20%检定点");
    chkVOLT_20->setFont(ft);
    connect(chkVOLT_20,SIGNAL(clicked()),this,SLOT(onStateChanged_Volt()));

    chkVOLT_50 = new QCheckBox("50%检定点");
    chkVOLT_50->setFont(ft);
    connect(chkVOLT_50,SIGNAL(clicked()),this,SLOT(onStateChanged_Volt()));

    chkVOLT_80 = new QCheckBox("80%检定点");
    chkVOLT_80->setFont(ft);
    connect(chkVOLT_80,SIGNAL(clicked()),this,SLOT(onStateChanged_Volt()));

    chkVOLT_100 = new QCheckBox("100%检定点");
    chkVOLT_100->setFont(ft);
    connect(chkVOLT_100,SIGNAL(clicked()),this,SLOT(onStateChanged_Volt()));

    chkVOLT_120 = new QCheckBox("120%检定点");
    chkVOLT_120->setFont(ft);
    connect(chkVOLT_120,SIGNAL(clicked()),this,SLOT(onStateChanged_Volt()));

    QVBoxLayout *Vlay3rd = new QVBoxLayout;
    Vlay3rd->addWidget(chkVOLT);
    Vlay3rd->addWidget(chkVOLT_20);
    Vlay3rd->addWidget(chkVOLT_50);
    Vlay3rd->addWidget(chkVOLT_80);
    Vlay3rd->addWidget(chkVOLT_100);
    Vlay3rd->addWidget(chkVOLT_120);

    btnAll = new QPushButton("全不选");
    btnAll->setFont(ft);
    btnAll->setFixedSize(100,40);
    connect(btnAll,SIGNAL(clicked()),this,SLOT(selectAll()));

    QVBoxLayout *VlayMain = new QVBoxLayout;
    VlayMain->addLayout(Vlay3rd);
    VlayMain->addLayout(Vlay2nd);
    VlayMain->addLayout(Vlay1st);
    VlayMain->addWidget(btnAll);
    VlayMain->setContentsMargins(20,30,0,0);

    QGroupBox *boxTestCfg = new QGroupBox;
    boxTestCfg->setLayout(VlayMain);
    boxTestCfg->setFixedSize(300,600);
    boxTestCfg->setTitle("- 测试项目选择 -");
    boxTestCfg->setStyleSheet(".QGroupBox{border-radius:5px;font-size:20px;}QGroupBox:title{color:#cac9ce;}");

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(boxTestCfg);

    theWidget->setLayout(layout);

    chkCURR->setChecked(true);
    chkVOLT->setChecked(true);
}

void pageAutoVerify::layDataTP(QWidget *theWidget)
{
    QFont ft;
    ft.setPixelSize(20);
    ft.setBold(true);

    QLabel *labTip_TP = new QLabel("-时间性能测量数据-");
    labTip_TP->setFont(ft);
    labTip_TP->setStyleSheet(".QLabel{color:#cac9ce}");

    ft.setBold(false);

    model_TP = new QStandardItemModel();
    model_TP->setColumnCount(2);
    model_TP->setRowCount(6);

    QModelIndex index;
    index = model_TP->index(0,0,QModelIndex());
    model_TP->setData(index,tr("测试时间(分钟)"));
    model_TP->item(0,0)->setFont(ft);

    index = model_TP->index(0,1,QModelIndex());
    model_TP->setData(index,tr("10"));
    model_TP->item(0,1)->setTextAlignment(Qt::AlignCenter);
    model_TP->item(0,1)->setFont(ft);

    index = model_TP->index(1,0,QModelIndex());
    model_TP->setData(index,tr("采样值响应时间(us)"));
    model_TP->item(1,0)->setFont(ft);

    index = model_TP->index(2,0,QModelIndex());
    model_TP->setData(index,tr("额定延时(us)"));
    model_TP->item(2,0)->setFont(ft);

    index = model_TP->index(3,0,QModelIndex());
    model_TP->setData(index,tr("对时误差(us)"));
    model_TP->item(3,0)->setFont(ft);

    index = model_TP->index(4,0,QModelIndex());
    model_TP->setData(index,tr("最大对时误差(us)"));
    model_TP->item(4,0)->setFont(ft);

    index = model_TP->index(5,0,QModelIndex());
    model_TP->setData(index,tr("结论"));
    model_TP->item(5,0)->setFont(ft);

    QTableView *tbvTP = new QTableView;
    tbvTP->setModel(model_TP);
    tbvTP->horizontalHeader()->hide();
    tbvTP->verticalHeader()->hide();
    tbvTP->setSelectionBehavior(QAbstractItemView::SelectRows);
    tbvTP->setEditTriggers(QAbstractItemView::NoEditTriggers);

    tbvTP->setColumnWidth(0, 300);
    tbvTP->setColumnWidth(1, 300);

    tbvTP->setRowHeight(0,40);
    tbvTP->setRowHeight(1,40);
    tbvTP->setRowHeight(2,40);
    tbvTP->setRowHeight(3,40);
    tbvTP->setRowHeight(4,40);
    tbvTP->setRowHeight(5,40);
    tbvTP->setFixedSize(602,242);

    QVBoxLayout *layMain = new QVBoxLayout;
    layMain->addStretch(1);
    layMain->addWidget(labTip_TP);
    layMain->addWidget(tbvTP);
    layMain->addStretch(1);
    layMain->setAlignment(Qt::AlignCenter);

    theWidget->setLayout(layMain);
}

void pageAutoVerify::layDataCP(QWidget *theWidget)
{
    QFont ft;
    ft.setPixelSize(20);
    ft.setBold(true);

    QLabel *labTip_CP = new QLabel("-通信性能测量数据-");
    labTip_CP->setFont(ft);
    labTip_CP->setStyleSheet(".QLabel{color:#cac9ce}");

    ft.setBold(false);

    model_CP = new QStandardItemModel();
    model_CP->setColumnCount(2);
    model_CP->setRowCount(8);

    QModelIndex index;
    index = model_CP->index(0,0,QModelIndex());
    model_CP->setData(index,tr("总报文数"));
    model_CP->item(0,0)->setFont(ft);

    index = model_CP->index(1,0,QModelIndex());
    model_CP->setData(index,tr("丢失报文数"));
    model_CP->item(1,0)->setFont(ft);

    index = model_CP->index(2,0,QModelIndex());
    model_CP->setData(index,tr("错序报文"));
    model_CP->item(2,0)->setFont(ft);

    index = model_CP->index(3,0,QModelIndex());
    model_CP->setData(index,tr("偏差小于2us(%)"));
    model_CP->item(3,0)->setFont(ft);

    index = model_CP->index(4,0,QModelIndex());
    model_CP->setData(index,tr("偏差小于2-4us(%)"));
    model_CP->item(4,0)->setFont(ft);

    index = model_CP->index(5,0,QModelIndex());
    model_CP->setData(index,tr("偏差小于4-10us(%)"));
    model_CP->item(5,0)->setFont(ft);

    index = model_CP->index(6,0,QModelIndex());
    model_CP->setData(index,tr("偏差大于10us(%)"));
    model_CP->item(6,0)->setFont(ft);

    index = model_CP->index(7,0,QModelIndex());
    model_CP->setData(index,tr("结论"));
    model_CP->item(7,0)->setFont(ft);

    QTableView *tbvCP = new QTableView;
    tbvCP->setModel(model_CP);
    tbvCP->horizontalHeader()->hide();
    tbvCP->verticalHeader()->hide();
    tbvCP->setSelectionBehavior(QAbstractItemView::SelectRows);
    tbvCP->setEditTriggers(QAbstractItemView::NoEditTriggers);

    tbvCP->setColumnWidth(0, 300);
    tbvCP->setColumnWidth(1, 300);

    tbvCP->setRowHeight(0,40);
    tbvCP->setRowHeight(1,40);
    tbvCP->setRowHeight(2,40);
    tbvCP->setRowHeight(3,40);
    tbvCP->setRowHeight(4,40);
    tbvCP->setRowHeight(5,40);
    tbvCP->setRowHeight(6,40);
    tbvCP->setRowHeight(7,40);
    tbvCP->setFixedSize(602,322);

    QVBoxLayout *layMain = new QVBoxLayout;
    layMain->addStretch(1);
    layMain->addWidget(labTip_CP);
    layMain->addWidget(tbvCP);
    layMain->addStretch(1);
    layMain->setAlignment(Qt::AlignCenter);

    theWidget->setLayout(layMain);
}

void pageAutoVerify::layDataCURR(QWidget *theWidget)
{
    QFont ft;
    ft.setPixelSize(20);
    ft.setBold(true);

    QLabel *labTip_CURR = new QLabel("-自动测量电流数据-");
    labTip_CURR->setFont(ft);
    labTip_CURR->setStyleSheet(".QLabel{color:#cac9ce}");

    ft.setBold(false);

    model_CURR = new QStandardItemModel();
    model_CURR->setColumnCount(7);
    model_CURR->setRowCount(7);

    QModelIndex index;
    index = model_CURR->index(0,0,QModelIndex());
    model_CURR->setData(index,tr("电流测量点"));
    model_CURR->item(0,0)->setFont(ft);

    index = model_CURR->index(0,1,QModelIndex());
    model_CURR->setData(index,tr("IA"));
    model_CURR->item(0,1)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(0,1)->setFont(ft);

    index = model_CURR->index(0,3,QModelIndex());
    model_CURR->setData(index,tr("IB"));
    model_CURR->item(0,3)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(0,3)->setFont(ft);

    index = model_CURR->index(0,5,QModelIndex());
    model_CURR->setData(index,tr("IC"));
    model_CURR->item(0,5)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(0,5)->setFont(ft);

    index = model_CURR->index(1,1,QModelIndex());
    model_CURR->setData(index,tr("比差(%)"));
    model_CURR->item(1,1)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(1,1)->setFont(ft);

    index = model_CURR->index(1,2,QModelIndex());
    model_CURR->setData(index,tr("角差(‘)"));
    model_CURR->item(1,2)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(1,2)->setFont(ft);

    index = model_CURR->index(1,3,QModelIndex());
    model_CURR->setData(index,tr("比差(%)"));
    model_CURR->item(1,3)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(1,3)->setFont(ft);

    index = model_CURR->index(1,4,QModelIndex());
    model_CURR->setData(index,tr("角差(’)"));
    model_CURR->item(1,4)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(1,4)->setFont(ft);

    index = model_CURR->index(1,5,QModelIndex());
    model_CURR->setData(index,tr("比差(%)"));
    model_CURR->item(1,5)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(1,5)->setFont(ft);

    index = model_CURR->index(1,6,QModelIndex());
    model_CURR->setData(index,tr("角差(‘)"));
    model_CURR->item(1,6)->setTextAlignment(Qt::AlignCenter);
    model_CURR->item(1,6)->setFont(ft);

    index = model_CURR->index(2,0,QModelIndex());
    model_CURR->setData(index,tr("5%检定点"));
    model_CURR->item(2,0)->setFont(ft);

    index = model_CURR->index(3,0,QModelIndex());
    model_CURR->setData(index,tr("20%检定点"));
    model_CURR->item(3,0)->setFont(ft);

    index = model_CURR->index(4,0,QModelIndex());
    model_CURR->setData(index,tr("100%检定点"));
    model_CURR->item(4,0)->setFont(ft);

    index = model_CURR->index(5,0,QModelIndex());
    model_CURR->setData(index,tr("120%检定点"));
    model_CURR->item(5,0)->setFont(ft);

    index = model_CURR->index(6,0,QModelIndex());
    model_CURR->setData(index,tr("结论"));
    model_CURR->item(6,0)->setFont(ft);

    QTableView *tbvCURR = new QTableView;
    tbvCURR->setModel(model_CURR);
    tbvCURR->horizontalHeader()->hide();
    tbvCURR->verticalHeader()->hide();
    tbvCURR->setSelectionBehavior(QAbstractItemView::SelectRows);
    tbvCURR->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tbvCURR->setSpan(0,0,2,1);
    tbvCURR->setSpan(0,1,1,2);
    tbvCURR->setSpan(0,3,1,2);
    tbvCURR->setSpan(0,5,1,2);

    tbvCURR->setColumnWidth(0, 128);
    tbvCURR->setColumnWidth(1, 146);
    tbvCURR->setColumnWidth(2, 146);
    tbvCURR->setColumnWidth(3, 146);
    tbvCURR->setColumnWidth(4, 146);
    tbvCURR->setColumnWidth(5, 146);
    tbvCURR->setColumnWidth(6, 146);

    tbvCURR->setRowHeight(0,30);
    tbvCURR->setRowHeight(1,30);
    tbvCURR->setRowHeight(2,40);
    tbvCURR->setRowHeight(3,40);
    tbvCURR->setRowHeight(4,40);
    tbvCURR->setRowHeight(5,40);
    tbvCURR->setRowHeight(6,40);
    tbvCURR->setFixedSize(1006,262);

    QVBoxLayout *layMain = new QVBoxLayout;
    layMain->addStretch(1);
    layMain->addWidget(labTip_CURR);
    layMain->addWidget(tbvCURR);
    layMain->addStretch(1);

    theWidget->setLayout(layMain);
}

void pageAutoVerify::layDataVOLT(QWidget *theWidget)
{
    QFont ft;
    ft.setPixelSize(20);
    ft.setBold(true);

    QLabel *labTip_VOLT = new QLabel("-自动测量电压数据-");
    labTip_VOLT->setFont(ft);
    labTip_VOLT->setStyleSheet(".QLabel{color:#cac9ce}");

    ft.setBold(false);

    model_VOLT = new QStandardItemModel();
    model_VOLT->setColumnCount(7);
    model_VOLT->setRowCount(8);

    QModelIndex index;
    index = model_VOLT->index(0,0,QModelIndex());
    model_VOLT->setData(index,tr("电压测量点"));
    model_VOLT->item(0,0)->setFont(ft);

    index = model_VOLT->index(0,1,QModelIndex());
    model_VOLT->setData(index,tr("UA"));
    model_VOLT->item(0,1)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(0,1)->setFont(ft);

    index = model_VOLT->index(0,3,QModelIndex());
    model_VOLT->setData(index,tr("UB"));
    model_VOLT->item(0,3)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(0,3)->setFont(ft);

    index = model_VOLT->index(0,5,QModelIndex());
    model_VOLT->setData(index,tr("UC"));
    model_VOLT->item(0,5)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(0,5)->setFont(ft);

    index = model_VOLT->index(1,1,QModelIndex());
    model_VOLT->setData(index,tr("比差(%)"));
    model_VOLT->item(1,1)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(1,1)->setFont(ft);

    index = model_VOLT->index(1,2,QModelIndex());
    model_VOLT->setData(index,tr("角差(‘)"));
    model_VOLT->item(1,2)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(1,2)->setFont(ft);

    index = model_VOLT->index(1,3,QModelIndex());
    model_VOLT->setData(index,tr("比差(%)"));
    model_VOLT->item(1,3)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(1,3)->setFont(ft);

    index = model_VOLT->index(1,4,QModelIndex());
    model_VOLT->setData(index,tr("角差(’)"));
    model_VOLT->item(1,4)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(1,4)->setFont(ft);

    index = model_VOLT->index(1,5,QModelIndex());
    model_VOLT->setData(index,tr("比差(%)"));
    model_VOLT->item(1,5)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(1,5)->setFont(ft);

    index = model_VOLT->index(1,6,QModelIndex());
    model_VOLT->setData(index,tr("角差(‘)"));
    model_VOLT->item(1,6)->setTextAlignment(Qt::AlignCenter);
    model_VOLT->item(1,6)->setFont(ft);

    index = model_VOLT->index(2,0,QModelIndex());
    model_VOLT->setData(index,tr("20%检定点"));
    model_VOLT->item(2,0)->setFont(ft);

    index = model_VOLT->index(3,0,QModelIndex());
    model_VOLT->setData(index,tr("50%检定点"));
    model_VOLT->item(3,0)->setFont(ft);

    index = model_VOLT->index(4,0,QModelIndex());
    model_VOLT->setData(index,tr("80%检定点"));
    model_VOLT->item(4,0)->setFont(ft);

    index = model_VOLT->index(5,0,QModelIndex());
    model_VOLT->setData(index,tr("100%检定点"));
    model_VOLT->item(5,0)->setFont(ft);

    index = model_VOLT->index(6,0,QModelIndex());
    model_VOLT->setData(index,tr("120%检定点"));
    model_VOLT->item(6,0)->setFont(ft);

    index = model_VOLT->index(7,0,QModelIndex());
    model_VOLT->setData(index,tr("结论"));
    model_VOLT->item(7,0)->setFont(ft);

    QTableView *tbvVOLT = new QTableView;
    tbvVOLT->setModel(model_VOLT);
    tbvVOLT->horizontalHeader()->hide();
    tbvVOLT->verticalHeader()->hide();
    tbvVOLT->setSelectionBehavior(QAbstractItemView::SelectRows);
    tbvVOLT->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tbvVOLT->setSpan(0,0,2,1);
    tbvVOLT->setSpan(0,1,1,2);
    tbvVOLT->setSpan(0,3,1,2);
    tbvVOLT->setSpan(0,5,1,2);

    tbvVOLT->setColumnWidth(0, 128);
    tbvVOLT->setColumnWidth(1, 146);
    tbvVOLT->setColumnWidth(2, 146);
    tbvVOLT->setColumnWidth(3, 146);
    tbvVOLT->setColumnWidth(4, 146);
    tbvVOLT->setColumnWidth(5, 146);
    tbvVOLT->setColumnWidth(6, 146);

    tbvVOLT->setRowHeight(0,30);
    tbvVOLT->setRowHeight(1,30);
    tbvVOLT->setRowHeight(2,40);
    tbvVOLT->setRowHeight(3,40);
    tbvVOLT->setRowHeight(4,40);
    tbvVOLT->setRowHeight(5,40);
    tbvVOLT->setRowHeight(6,40);
    tbvVOLT->setRowHeight(7,40);
    tbvVOLT->setFixedSize(1006,302);

    QVBoxLayout *layMain = new QVBoxLayout;
    layMain->addStretch(1);
    layMain->addWidget(labTip_VOLT);
    layMain->addWidget(tbvVOLT);
    layMain->addStretch(1);

    theWidget->setLayout(layMain);
}

void pageAutoVerify::SelectAllCurrTestPoint(int state)
{
    if (state == Qt::Checked)
    {
        chkCURR_5->setChecked(true);
        chkCURR_20->setChecked(true);
        chkCURR_100->setChecked(true);
        chkCURR_120->setChecked(true);
    }
    else if(state == Qt::Unchecked)
    {
        chkCURR_5->setChecked(false);
        chkCURR_20->setChecked(false);
        chkCURR_100->setChecked(false);
        chkCURR_120->setChecked(false);
    }
}

void pageAutoVerify::SelectAllVoltTestPoint(int state)
{
    if (state == Qt::Checked)
    {
        chkVOLT_20->setChecked(true);
        chkVOLT_50->setChecked(true);
        chkVOLT_80->setChecked(true);
        chkVOLT_100->setChecked(true);
        chkVOLT_120->setChecked(true);
    }
    else if (state == Qt::Unchecked)
    {
        chkVOLT_20->setChecked(false);
        chkVOLT_50->setChecked(false);
        chkVOLT_80->setChecked(false);
        chkVOLT_100->setChecked(false);
        chkVOLT_120->setChecked(false);
    }
}

void pageAutoVerify::onStateChanged_Curr()
{
    if (chkCURR_5->isChecked() && chkCURR_20->isChecked() && chkCURR_100->isChecked() && chkCURR_120->isChecked())
    {
        chkCURR->setCheckState(Qt::Checked);
        isSelectCurrAll = true;
    }
    else if ((chkCURR_5->isChecked() == false) && (chkCURR_20->isChecked() == false) && (chkCURR_100->isChecked() == false) && (chkCURR_120->isChecked() == false))
    {
        chkCURR->setCheckState(Qt::Unchecked);
        isSelectCurrAll = false;
    }
    else
    {
        chkCURR->setCheckState(Qt::PartiallyChecked);
        isSelectCurrAll = false;
    }
}

void pageAutoVerify::onStateChanged_Volt()
{
    if (chkVOLT_20->isChecked() && chkVOLT_50->isChecked() && chkVOLT_80->isChecked() && chkVOLT_100->isChecked() && chkVOLT_120->isChecked())
    {
        chkVOLT->setCheckState(Qt::Checked);
        isSelectVoltAll = true;
    }
    else if ((chkVOLT_20->isChecked() == false) && (chkVOLT_50->isChecked() == false) && (chkVOLT_80->isChecked() == false)
             && (chkVOLT_100->isChecked() == false) && (chkVOLT_120->isChecked() == false))
    {
        chkVOLT->setCheckState(Qt::Unchecked);
        isSelectVoltAll = false;
    }
    else
    {
        chkVOLT->setCheckState(Qt::PartiallyChecked);
        isSelectVoltAll = false;
    }
}

void pageAutoVerify::changeCurrState()
{
    if (isSelectCurrAll)
    {
        chkCURR->setCheckState(Qt::Unchecked);
        isSelectCurrAll = false;
    }
    else
    {
        chkCURR->setCheckState(Qt::Checked);
        isSelectCurrAll = true;
    }
}

void pageAutoVerify::changeVoltState()
{
    if (isSelectVoltAll)
    {
        chkVOLT->setCheckState(Qt::Unchecked);
        isSelectVoltAll = false;
    }
    else
    {
        chkVOLT->setCheckState(Qt::Checked);
        isSelectVoltAll = true;
    }
}

void pageAutoVerify::selectAll()
{
    if (btnAll->text() == "全选")
    {
        btnAll->setText("全不选");
        chkTP->setChecked(true);
        chkCP->setChecked(true);
        chkCURR->setChecked(true);
        chkVOLT->setChecked(true);
    }
    else
    {
        btnAll->setText("全选");
        chkTP->setChecked(false);
        chkCP->setChecked(false);
        chkCURR->setChecked(false);
        chkVOLT->setChecked(false);
    }
}

bool pageAutoVerify::test()
{
    qDebug()<<"pageAutoVerify::test()";

    if (btnTest->text() == "开始测量")
    {
        if (chkTP->isChecked() == false && chkCP->isChecked() == false && chkCURR->isChecked() == false && chkVOLT->isChecked() == false)
        {
            return false;
        }

        btnTest->setText("停止测量");

        if (chkVOLT->isChecked())
        {
            theStaWid->addWidget(widDataVOLT);
        }
        if (chkCURR->isChecked())
        {
            theStaWid->addWidget(widDataCURR);
        }
        if (chkTP->isChecked())
        {
            theStaWid->addWidget(widDataTP);
        }
        if (chkCP->isChecked())
        {
            theStaWid->addWidget(widDataCP);
        }

        theStaWid->setCurrentIndex(page);
        if (theStaWid->count() >= 3)
        {
            btnPre->setVisible(true);
            btnNext->setVisible(true);
        }
        return true;
    }
    else
    {
        btnTest->setText("开始测量");
        btnPre->setVisible(false);
        btnNext->setVisible(false);

        theStaWid->removeWidget(widDataTP);
        theStaWid->removeWidget(widDataCP);
        theStaWid->removeWidget(widDataCURR);
        theStaWid->removeWidget(widDataVOLT);
        page = 1;
        return false;
    }
}

void pageAutoVerify::prePage()
{
    page--;
    if (page == 0)
    {
        page = theStaWid->count() - 1;
    }
    theStaWid->setCurrentIndex(page);
}

void pageAutoVerify::nextPage()
{
    page++;
    if (page == theStaWid->count())
    {
        page = 1;
    }
    theStaWid->setCurrentIndex(page);
}

void pageAutoVerify::setDataTP(QString str)
{
    QFont ft;
    ft.setPixelSize(20);

    QStringList strlist = str.split(";");

    QModelIndex index;
    int num = 0;

    for (int i = 1; i < 5; i++)
    {
        index = model_TP->index(i,1,QModelIndex());
        model_TP->setData(index,strlist.at(num++));
        model_TP->item(i,1)->setTextAlignment(Qt::AlignCenter);
        model_TP->item(i,1)->setFont(ft);
    }
}

void pageAutoVerify::setDataCP(QString str)
{
    QFont ft;
    ft.setPixelSize(20);

    QStringList strlist = str.split(";");

    QModelIndex index;
    int num = 0;

    for (int i = 0; i < 7; i++)
    {
        index = model_CP->index(i,1,QModelIndex());
        model_CP->setData(index,strlist.at(num++));
        model_CP->item(i,1)->setTextAlignment(Qt::AlignCenter);
        model_CP->item(i,1)->setFont(ft);
    }
}

void pageAutoVerify::setDataCURR(QString str)
{
    QFont ft;
    ft.setPixelSize(20);

    QStringList strlist = str.split(";");

    QModelIndex index;

    int num = 0;

    for (int i = 2; i < 6; i++)
    {
        for (int j = 1; j < 7; j++)
        {
            index = model_CURR->index(i,j,QModelIndex());
            model_CURR->setData(index,strlist.at(num++));
            model_CURR->item(i,j)->setTextAlignment(Qt::AlignCenter);
            model_CURR->item(i,j)->setFont(ft);
        }
    }
}

void pageAutoVerify::setDataVOLT(QString str)
{
    QFont ft;
    ft.setPixelSize(20);

    QStringList strlist = str.split(";");

    QModelIndex index;

    int num = 0;

    for (int i = 2; i < 7; i++)
    {
        for (int j = 1; j < 7; j++)
        {
            index = model_VOLT->index(i,j,QModelIndex());
            model_VOLT->setData(index,strlist.at(num++));
            model_VOLT->item(i,j)->setTextAlignment(Qt::AlignCenter);
            model_VOLT->item(i,j)->setFont(ft);
        }
    }
}
